
<UserControl
	x:Name="AccountInformation"
	x:Class="Goldlight.SampleApplication.Views.AccountInformationView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:vm="clr-namespace:Goldlight.SampleApplication.ViewModels"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	DataContext="{DynamicResource VM}"
	>
	<UserControl.Resources>
		<vm:AccountInformationViewModel x:Key="VM"/>
		<Style TargetType="{x:Type Label}">
			<Setter Property="Padding" Value="6"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
		</Style>
		<Style TargetType="{x:Type TextBox}">
			<Setter Property="Width" Value="150"/>
			<Setter Property="Margin" Value="0,0,10,0"/>
		</Style>
		<Style TargetType="{x:Type ComboBox}">
			<Setter Property="Width" Value="150"/>
			<Setter Property="Margin" Value="0,0,10,0"/>
		</Style>
		<DataTemplate x:Key="CountryTemplate">
			<StackPanel>
				<TextBlock Text="{Binding Name}"/>
			</StackPanel>
		</DataTemplate>
		<ControlTemplate x:Key="ValidationTemplate">
			<DockPanel>
				<AdornedElementPlaceholder/>
				<TextBlock
					FontSize="20"
					Foreground="Red"
					Text="*"
					ToolTip="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Resources.ChooseItem}"/>
			</DockPanel>
		</ControlTemplate>
	</UserControl.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>
		<Label Grid.Column="0" Grid.Row="0" Content="{Binding Resources.AccountName}"/>
		<Label Grid.Column="0" Grid.Row="1" Content="{Binding Resources.AccountNumber}"/>
		<Label Grid.Column="0" Grid.Row="2" Content="{Binding Resources.AddressName}"/>
		<Label Grid.Column="0" Grid.Row="3" Content="{Binding Resources.ParentAccount}"/>
		<Label Grid.Column="0" Grid.Row="4" Content="{Binding Resources.Street1}"/>
		<Label Grid.Column="0" Grid.Row="5" Content="{Binding Resources.Street2}"/>
		<Label Grid.Column="0" Grid.Row="6" Content="{Binding Resources.Street3}"/>
		<Label Grid.Column="0" Grid.Row="7" Content="{Binding Resources.County}"/>
		<Label Grid.Column="0" Grid.Row="8" Content="{Binding Resources.City}"/>
		<Label Grid.Column="0" Grid.Row="9" Content="{Binding Resources.PostCode}"/>
		<Label Grid.Column="0" Grid.Row="10" Content="{Binding Resources.Country}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="0"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			MaxLength="100"
			Text="{Binding Path=AccountName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="1"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			MaxLength="100"
			Text="{Binding Path=AccountNumber, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="2"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=AddressName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="3"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=ParentAccount, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="4"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=Street1, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="5"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=Street2, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="6"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=Street3, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="7"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=County, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="8"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=City, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<TextBox
			Grid.Column="1"
			Grid.Row="9"
			HorizontalAlignment="Left"
			VerticalAlignment="Top"
			Text="{Binding Path=PostCode, Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
		<ComboBox
			x:Name="cboCountry"
			Grid.Column="1"
			Grid.Row="10"
			IsEditable="False"
			IsSynchronizedWithCurrentItem="True"
			ItemTemplate="{StaticResource CountryTemplate}"
			SelectedIndex="0"
			Validation.ErrorTemplate="{StaticResource ValidationTemplate}"
			>
			<ComboBox.SelectedItem>
				<Binding ElementName="AccountInformation" Mode="OneWayToSource" Path="SelectedCountry">
					<Binding.ValidationRules>
						<vm:CountryValidation/>
					</Binding.ValidationRules>
				</Binding>
			</ComboBox.SelectedItem>
			<ComboBox.ItemsSource>
				<CompositeCollection>
					<ComboBoxItem x:Name="selectText" />
					<CollectionContainer x:Name="countryCollection" />
				</CompositeCollection>
			</ComboBox.ItemsSource>
		</ComboBox>
	</Grid>
</UserControl>